import 'package:flutter/material.dart';
import 'package:github_client_app/page/assets/person.dart';
import 'package:github_client_app/router/navigator_util.dart';

class ParamsPage extends StatefulWidget {
  ParamsPage({Key? key}) : super(key: key);
  // Person p;

  @override
  _ParamsPageState createState() => _ParamsPageState();
}

class _ParamsPageState extends State<ParamsPage> {
  @override
  Widget build(BuildContext context) {
    // print(context);
    // 路由传参
    var arguments = ModalRoute.of(context)?.settings.arguments;
    Person? p;
    if (arguments is Person) {
      p = arguments;
    }
    return Scaffold(
      appBar: AppBar(
        title: const Text('params'),
      ),
      body: Center(
          child: Column(
        children: [
          Text('${p?.name}'),
          Text('${p?.habby}'),
          Text('${p?.age}'),
          ElevatedButton(
              onPressed: () {
                NavigatorUtil.back(context);
              },
              child: const Text('返回'))
        ],
      )),
    );
  }
}
